#import <Foundation/Foundation.h>
#import <gtk/gtk.h>

gint count = 0;
char buf[5];

void inc(GtkWidget *widget,gpointer label){
	count++;
	snprintf(buf,sizeof(buf),"%d",count);
	gtk_label_set_text(label,buf);
}

void dec(GtkWidget *widget,gpointer label){
	count--;
	snprintf(buf,sizeof(buf),"%d",count);
	gtk_label_set_text(label,buf);
}

int main(int argc,char *argv[]){
	GtkWidget *label,*window,*frame,*btn_inc,*btn_dec;
	gtk_init(&argc,&argv);
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
	gtk_window_set_default_size(GTK_WINDOW(window),400,300);
	gtk_window_set_title(GTK_WINDOW(window),"Inc & Dec");
	frame = gtk_fixed_new();
	gtk_container_add(GTK_CONTAINER(window),frame);
	btn_inc = gtk_button_new_with_label("+");
	gtk_widget_set_size_request(btn_inc,80,35);
	gtk_fixed_put(GTK_FIXED(frame),btn_inc,50,20);
	btn_dec = gtk_button_new_with_label("-");
	gtk_widget_set_size_request(btn_dec,80,35);
	gtk_fixed_put(GTK_FIXED(frame),btn_dec,50,80);
	label = gtk_label_new("0");
	gtk_fixed_put(GTK_FIXED(frame),label,190,58);
	gtk_widget_show_all(window);

	g_signal_connect(window,"destroy",G_CALLBACK(gtk_main_quit),NULL);
	//g_signal_connect(btn_inc,"clicked",G_CALLBACK(inc),label);
	g_signal_connect(btn_inc,"pressed",G_CALLBACK(inc),label);

	g_signal_connect(btn_dec,"clicked",G_CALLBACK(dec),label);
	gtk_main();
	NSLog(@"%s:at last",__func__);
	return 0;
}
